<template>
<Form :ref="formRef" :model="item" :label-width="100">
    <FormItem v-if="item.title!==undefined" label="标题" prop="title" required>
        <Input v-model="item.title" />
    </FormItem>
    <FormItem v-if="item.picture!==undefined" label="预览图" prop="picture">
        <picture-single v-model="item" prop="picture"></picture-single>
    </FormItem>
    <FormItem v-if="item.pictures!==undefined" label="图片集" prop="pictures">
        <picture-box v-model="item.pictures"></picture-box>
    </FormItem>
    <FormItem v-if="item.description!==undefined" label="简介" prop="description">
        <Input v-model="item.description" type="textarea" :rows="3" />
    </FormItem>
    <FormItem v-if="item.content!==undefined" label="内容" prop="content">
        <editor :model=item prop="content"></editor>
    </FormItem>
    <FormItem v-if="item.tags!==undefined" label="标签" prop="tags">
        <tags v-model="item.tags" w10></tags>
    </FormItem>
    <FormItem v-if="item.author!==undefined" label="作者" prop="author">
        <Input v-model="item.author" />
    </FormItem>
    <FormItem v-if="item.source!==undefined" label="来源" prop="source">
        <Input v-model="item.source" />
    </FormItem>
    <FormItem v-if="item.creationTime!==undefined" label="添加时间" prop="creationTime">
        <Input :value="formatTimeStr(item.creationTime)" disabled />
    </FormItem>
    <FormItem v-if="item.status!==undefined" label="状态" prop="status" required>
        <RadioGroup v-model="item.status">
            <Radio :label="0">草稿</Radio>
            <Radio :label="1">待审核</Radio>
            <Radio :label="2">审核通过</Radio>
        </RadioGroup>
    </FormItem>
</Form>
</template>

<script lang="ts">
import { Component, Vue,Inject, Prop,Watch } from 'vue-property-decorator';
import AbpBase from '../../lib/abpbase'
import PictureSingle from '@common/components/picture-single.vue'
import PictureBox from '@common/components/picture-box.vue'
import Editor from './editor.vue'
import Tags from '@common/components/tags.vue'

@Component({
    components: { PictureSingle, PictureBox, Editor, Tags }
})
export default class Article extends AbpBase{
    @Prop() value:any;
    formRef:string = 'article-' + Date.now();
    get item() {
        return this.value;
    }
    validate(callback:Function) {
        (this.$refs[this.formRef] as any).validate(valid => {
            if(valid) {
                callback();
            }
        })
    }
}
</script>

<style>

</style>
